Skip to content

fix: install Claude Code AI plugin in user and project scopes#451

Draft
skoob13 wants to merge 2 commits into
mainfrom
posthog-code/install-claude-plugin-user-and-project
Draft

fix: install Claude Code AI plugin in user and project scopes#451
skoob13 wants to merge 2 commits into
mainfrom
posthog-code/install-claude-plugin-user-and-project

Conversation

@skoob13
Copy link
Copy Markdown

@skoob13 skoob13 commented May 12, 2026

Summary

  • The wizard previously ran claude plugin install posthog, which defaults to the user scope only (global to the developer, across all projects).
  • It now additionally installs with --scope project, persisting the plugin to the repo's .claude/settings.json so collaborators get the AI plugin too when they pick up the project.
  • The new logic considers the install successful if either scope succeeds, so a stricter project-scope failure (e.g. an unwritable .claude/) does not regress the existing global-install path. alreadyInstalled is only true when both scopes report the plugin is already in place.

Why

The wizard exists to set up PostHog for a project. The AI plugin is part of that setup, so it should land in both places:

  • User scope (~/.claude/settings.json) — the dev keeps the plugin everywhere they work.
  • Project scope (.claude/settings.json, committed) — the rest of the team picks up the plugin via git without rerunning the wizard.

See Claude Code's configuration scopes for the precedence and persistence model.

Test plan

  • Unit tests in claude-code.test.ts cover: both scopes succeed, both report already-installed, one scope fails (overall success), both fail (overall failure), and no binary found.
  • `pnpm build` and `pnpm lint` clean.
  • Manual: run the wizard against a project with Claude Code installed, confirm the plugin appears in both `~/.claude/settings.json` and `.claude/settings.json`.

Created with PostHog Code

The wizard previously ran `claude plugin install posthog`, which defaults
to user scope only. Now also install with `--scope project` so the plugin
is recorded in `.claude/settings.json` for collaborators on the repo, in
addition to the existing per-user install.

Overall success is reported if at least one scope succeeds, so a stricter
project scope failure (e.g. write-protected `.claude/`) does not regress
the existing user-scope behavior.

Generated-By: PostHog Code
Task-Id: 66273d08-6eb4-42cf-96b7-ddfe48159e2b
@github-actions
Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci misc
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci misc/quack-quack
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

Adds a `PluginScope` parameter ('user' | 'project' | 'both') to the
plugin install path and a scope picker in `McpScreen` shown after
feature selection, when at least one selected client supports plugins
and `.git` exists in the working directory. User scope is the default
(matches the previous behavior); project scope writes the plugin to
`.claude/settings.json` so collaborators pick it up; "both" installs
to both places.

When no `.git` is present, the picker is skipped and the user-scope
default is used, since project scope would not be meaningful.

- plugin-client: new PluginScope type + DEFAULT_PLUGIN_SCOPE='user'
- claude-code: installPlugin(scope) runs `claude plugin install posthog
  --scope <scope>` for each requested scope; 'both' aggregates results
  (success if either succeeds, alreadyInstalled if both report so)
- codex: accepts the param but ignores it (no scope concept)
- mcp-installer: new optional scope arg forwarded to the orchestrator
  and into analytics
- McpScreen: new PluginScopeSelect phase shown only when meaningful
- Tests updated for the new defaults and scope plumbing

Generated-By: PostHog Code
Task-Id: 66273d08-6eb4-42cf-96b7-ddfe48159e2b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant